<?php require_once('../connections/con_gl.php'); ?>
<?php
$getquery = str_replace("+"," ",$_GET[query]);
mysql_select_db($database_con_gl, $con_gl);
$query_rtrans = stripslashes($getquery);
$rtrans = mysql_query($query_rtrans, $con_gl) or die(mysql_error());
$row_rtrans = mysql_fetch_assoc($rtrans);
$totalRows_rtrans = mysql_num_rows($rtrans);

mysql_select_db($database_con_gl, $con_gl);
$query_getcompany = "SELECT * FROM gl_company WHERE id = 1";
$getcompany = mysql_query($query_getcompany, $con_gl) or die(mysql_error());
$row_getcompany = mysql_fetch_assoc($getcompany);
$totalRows_getcompany = mysql_num_rows($getcompany);
?>
<div>
  <table width="745" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr valign="middle">
      <td width="20%" height="115" align="center" style="border:dashed 1px #333333;">LOGO</td>
      <td width="90%" height="115" align="center"><?php echo $row_getcompany['perusahaan']; ?><br>
      <?php echo $row_getcompany['alamat']; ?><br>
      Telp.<?php echo $row_getcompany['telp']; ?> Fax.<?php echo $row_getcompany['fax']; ?> </td>
      <td width="1%" height="115">&nbsp;</td>
    </tr>
	<tr valign="middle">
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
<?php do { ?>
<?php
mysql_select_db($database_con_gl, $con_gl);
$query_trans = "SELECT gl_trans.transaksi, gl_trans.pos, gl_trans.total FROM gl_trans WHERE gl_trans.no_ref='$row_rtrans[no_ref]' ORDER BY gl_trans.pos";
$trans = mysql_query($query_trans, $con_gl) or die(mysql_error());
$row_trans = mysql_fetch_assoc($trans);
$totalRows_trans = mysql_num_rows($trans);
?>
<span style="font-weight: bold;"><center><?php echo $row_rtrans['no_ref']; ?> - <?php echo $row_rtrans['keterangan'];?></center></span>
  <table width="745" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#BBBBBB">
    <tr bgcolor="#EEEEEE">
      <td width="12%"><span style="font-weight: bold">Tanggal</span></td>
      <td width="53%"><span style="font-weight: bold">Transaksi</span></td>
      <td width="18%"><span style="font-weight: bold">Debet</span></td>
      <td width="17%"><span style="font-weight: bold">Kredit</span></td>
    </tr>
	<?php $totd =0; $totk = 0; do { ?>
    <tr valign="top">
      <td><?php echo $row_rtrans['tgl']; ?></td>
      <td><?php echo $row_trans['transaksi']; ?></td>
      <td align="right"><?php if($row_trans['pos']=='D') { echo number_format($row_trans['total'],0,',','.').",-";$totd += $row_trans[total];}else{ echo "0,00";} ?></td>
      <td align="right"><?php if($row_trans['pos']=='K') { echo number_format($row_trans['total'],0,',','.').",-";$totk += $row_trans[total];}else{ echo "0,00";} ?></td>
    </tr>
	<?php } while ($row_trans = mysql_fetch_assoc($trans)); ?>
    <tr valign="top">
      <td>&nbsp;</td>
      <td align="right"><span style="font-weight: bold">Total :</span></td>
      <td align="right"><?php echo number_format($totd,0,',','.').",-";?></td>
      <td align="right"><?php echo number_format($totk,0,',','.').",-";?></td>
    </tr>
  </table><br />
  <?php } while ($row_rtrans = mysql_fetch_assoc($rtrans)); ?>
  <?php
mysql_free_result($getcompany);
?>
